<?php
$params = array_merge(
    require __DIR__.'/../../common/config/params.php',
    require __DIR__.'/../../common/config/params-local.php',
    require __DIR__.'/params.php',
    require __DIR__.'/params-local.php'
);

return [
    'id'                  => 'app-frontend',
    'basePath'            => dirname(__DIR__),
    'bootstrap'           => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'components'          => [
        'request'      => [
            'csrfParam' => '_csrf-frontend',
        ],
        'user'         => [
            'identityClass'   => 'frontend\models\User',
            'enableAutoLogin' => true,
            'identityCookie'  => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session'      => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'log'          => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets'    => [
                [
                    'class'  => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager'   => [
            'enablePrettyUrl'     => true,
            'showScriptName'      => false,
            'enableStrictParsing' => true,
            'suffix'              => '.html',//后缀，如果设置了此项，那么浏览器地址栏就必须带上.html后缀，否则会报404错误
            'rules'               => [
                //单页规则
                ''                         => '/site/index',
                'index'                    => '/site/index',
                '/index-layer'             => '/site/index-layer',
                '/contact'                 => '/site/contact',
                '/baidu'                 => '/site/baidu',
                '/about'                   => '/site/about',
                '/about/<id:\d+>'          => '/site/about',    //单页详情
                '<view:\w+>'               => '/site/list',     //大栏目规则
                '<view:\w+>/list/<id:\d+>' => '/site/list',     //列表页规则
                '<view:\w+>/view/<id:\d+>' => '/site/view',     //详情页规则
//                '/product/'         => '/product/index',      // 默认index
//                '/product/<action>' => '/product/<action>',

//                'index'       => '/site/index',
//                'ipr'        => '/site/ipr',
//                'index-layer' => '/site/index-layer',
            ],
        ],
    ],
    'as access'           => [
        'class'        => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            //这里是允许访问的action，不受权限控制
            //controller/action
            '*',
        ],
    ],
    'params'              => $params,
];
